package com.bluesky.dreamer.dao;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.transform.ResultTransformer;


/**
 * 
 * @author handong
 *
 */
public class MapResultTransFormer implements ResultTransformer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public List transformList(List collection) {
		return collection;
	}

	public Object transformTuple(Object[] tuple, String[] aliases) {
		Map result = new LinkedHashMap(tuple.length);
		for ( int i=0; i<tuple.length; i++ ) {
			String alias = aliases[i];
			if ( alias!=null ) {
				result.put( alias, tuple[i] );
			}
		}
		return result;
	}
}
